// 1. 导入所需模块
import Vue from 'vue'
import VueRouter from 'vue-router'


import MyHome from '@/components/MyHome'
import MyMovie from '@/components/MyMovie'
import MyMusic from '@/components/MyMusic'
import MyAbout from '@/components/MyAbout'

import AboutMe from '@/components/AboutMe'
import AboutYou from '@/components/AboutYou'

// 2. 调用 Vue.use() 函数，将 VueRouter 安装为 Vue 的插件
Vue.use(VueRouter)

// 3. 创建路由的实例对象
const router = new VueRouter({
  // 写路由规则(hash地址---->要展示的组件，对应关系)
  routes:[
    { path:'/home',component: MyHome},
    { path:'/movie',component: MyMovie},
    { path:'/music',component: MyMusic},
    { path:'/about',component: MyAbout,children: [
      // children里面的path，就不用写 / 了。最终的 hash 地址，是 父子hash地址拼接的结果
      // 也就是说，关于我 的地址是 /about/me
      // 如果自规则地址，以/开头 则最终的地址(不会)拼接
      {path:'/about/me',component: AboutMe},
      {path:'you',component: AboutYou}
    ] },

  ]
})

// 4. 导出路由的实例对象
export default router